package org.jie.mybatisplusdemo;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.sql.SQLException;
import java.util.Collections;

public class FastAutoGeneratorTest {

    public static final String URL = "jdbc:mysql://rm-uf6sz8gw8o63c51bpo.mysql.rds.aliyuncs.com/naked_cloud_dev?useSSL=false";
//    public static final String URL = "jdbc:mysql://rm-uf6sz8gw8o63c51bpo.mysql.rds.aliyuncs.com/booking_dev?useSSL=false";
//    public static final String URL = "jdbc:mysql://rm-uf6sz8gw8o63c51bpo.mysql.rds.aliyuncs.com/naked_wechat_dev?useSSL=false";
//    public static final String URL = "jdbc:mysql://rm-uf6sz8gw8o63c51bpo.mysql.rds.aliyuncs.com/nakednow_dev?useSSL=false";

    /**
     * 执行 run
     */
    public static void main(String[] args) throws SQLException {
        FastAutoGenerator.create(URL, "naked_cloud_dev", "QsJ7DdaKE3pl")
//        FastAutoGenerator.create(URL, "booking_dev", "f6t2QSA3qcXS")
//        FastAutoGenerator.create(URL, "naked_wechat_dev", "dhWu0cIKO!mu")
//        FastAutoGenerator.create(URL, "nakednow_dev", "ALVr&L@D@Y@5")
                .globalConfig(builder -> {
                    builder.author("jie") // 设置作者
                            .enableSwagger() // 开启 swagger 模式
                            .fileOverride() // 覆盖已生成文件
                            .outputDir("/Users/jie/dev/workspaces"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("com.naked.cloud") // 设置父包名
                            .moduleName("third.part") // 设置父包模块名
                            .pathInfo(Collections.singletonMap(OutputFile.mapperXml, "/Users/jie/dev/workspaces")); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.addInclude("tp_buggy_driver") // 设置需要生成的表名
                            .addTablePrefix("t_", "c_", "tp_","ps_","ums_"); // 设置过滤表前缀
                })
                .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .execute();

    }
}
